
#region Apache Notice
/*****************************************************************************
 * $Revision: 575902 $
 * $LastChangedDate: 2007-09-15 04:40:19 -0600 (Sat, 15 Sep 2007) $
 * $LastChangedBy: gbayon $
 * 
 * iBATIS.NET Data Mapper
 * Copyright (C) 2006/2005 - The Apache Software Foundation
 *  
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 ********************************************************************************/
#endregion

#region Using

using System;
using System.Collections;
#if NET_2_0
using System.Collections.Generic;
#endif
using System.Data;
using System.Text;

using IBatisNet.Common.Utilities.Objects;


using IBatisNet.DataMapper.Commands;
using IBatisNet.DataMapper.Configuration.ParameterMapping;
using IBatisNet.DataMapper.Configuration.Statements;
//using IBatisNet.DataMapper.MappedStatements.ResultStrategy;
using IBatisNet.DataMapper.Scope;
//using IBatisNet.DataMapper.MappedStatements.PostSelectStrategy;
using IBatisNet.DataMapper.Exceptions;
using IBatisNet.DataMapper.TypeHandlers;

#endregion

namespace IBatisNet.DataMapper.MappedStatements
{

    /// <summary>
    /// Summary description for MappedStatement.
    /// </summary>
    public class MappedStatement : IMappedStatement
    {
        /// <summary>
        /// Event launch on exceute query
        /// </summary>
        public event ExecuteEventHandler Execute;

        #region Fields

        // Magic number used to set the the maximum number of rows returned to 'all'. 
        internal const int NO_MAXIMUM_RESULTS = -1;
        // Magic number used to set the the number of rows skipped to 'none'. 
        internal const int NO_SKIPPED_RESULTS = -1;

        private IStatement _statement = null;
        private ISqlMapper _sqlMap = null;
        //private IPreparedCommand _preparedCommand = null;
        //private IResultStrategy _resultStrategy = null;
        #endregion

        #region Properties


        ///// <summary>
        ///// The IPreparedCommand to use
        ///// </summary>
        //public IPreparedCommand PreparedCommand
        //{
        //    get { return _preparedCommand; }
        //}

        /// <summary>
        /// Name used to identify the MappedStatement amongst the others.
        /// This the name of the SQL statement by default.
        /// </summary>
        public string Id
        {
            get { return _statement.Id; }
        }

        /// <summary>
        /// The SQL statment used by this MappedStatement
        /// </summary>
        public IStatement Statement
        {
            get { return _statement; }
        }

        /// <summary>
        /// The SqlMap used by this MappedStatement
        /// </summary>
        public ISqlMapper SqlMap
        {
            get { return _sqlMap; }
        }
        #endregion

        #region Constructor (s) / Destructor
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sqlMap">An SqlMap</param>
        /// <param name="statement">An SQL statement</param>
        internal MappedStatement(ISqlMapper sqlMap, IStatement statement)
        {
            _sqlMap = sqlMap;
            _statement = statement;
            //_preparedCommand = PreparedCommandFactory.GetPreparedCommand(false);
            //_resultStrategy = ResultStrategyFactory.Get(_statement);
        }
        #endregion

        #region Methods

          

        #region ExecuteQueryForList .NET 2.0
#if NET_2_0

            

#endif
        #endregion

        #region ExecuteUpdate, ExecuteInsert

       

        #endregion

        #region ExecuteQueryForMap

          
#if NET_2_0
         
#endif
        
        #endregion

          

        /// <summary>
        /// ToString implementation.
        /// </summary>
        /// <returns>A string that describes the MappedStatement</returns>
        public override string ToString()
        {
            StringBuilder buffer = new StringBuilder();
            buffer.Append("\tMappedStatement: " + this.Id);
            buffer.Append(Environment.NewLine);
            if (_statement.ParameterMap != null) buffer.Append(_statement.ParameterMap.Id);

            return buffer.ToString();
        }


        #endregion

    }
}
